package com.ruoyi.boc.service.impl;

import com.ruoyi.boc.mapper.BocCommonMapper;
import com.ruoyi.boc.service.IBocCommonService;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.entity.SysMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

@Service
public class BocCommonServiceImpl implements IBocCommonService
{
    @Autowired
    private BocCommonMapper commonMapper;


    @Override
    public HashMap findUserInfo(HashMap params) {
        return commonMapper.findUserInfo(params);
    }

    @Override
    public List<LinkedHashMap> selectCheckUsers(HashMap params) {
        return commonMapper.selectCheckUsers(params);
    }

    @Override
    public List<LinkedHashMap> selectCheckTeamUsers(HashMap params) {
        String deptsParams = "";
        String[] deptArray = params.get("deptIds").toString().split(",");
        deptsParams = "dept_id ='"+deptArray[0]+"'";
        if(deptArray.length >1){
            for(int i=1;i<deptArray.length;i++){
                deptsParams = deptsParams + " or dept_id in (select dept_id from sys_dept where parent_id ='"+deptArray[i]+"')";
            }
        }
        params.clear();
        params.put("deptsParams",deptsParams);
        return commonMapper.selectCheckTeamUsers(params);
    }

    @Override
    public List<LinkedHashMap> selectEmpowerUsers(HashMap params) {
        String deptsParams = "";
        String[] deptArray = params.get("deptIds").toString().split(",");
        deptsParams = "dept_id ='"+deptArray[0]+"'";
        if(deptArray.length >1){
            for(int i=1;i<deptArray.length;i++){
                deptsParams = deptsParams + " or dept_id in (select dept_id from sys_dept where parent_id ='"+deptArray[i]+"')";
            }
        }
        params.clear();
        params.put("deptsParams",deptsParams);
        return commonMapper.selectEmpowerUsers(params);
    }

    @Override
    public List<SysMenu> selectAuthMenuList(HashMap params) {
        return commonMapper.selectAuthMenuList(params);
    }

    @Override
    public HashMap findRptIsAuth(HashMap params) {
        return commonMapper.findRptIsAuth(params);
    }
}
